package zdream.pmfield.stage.buff.ability;

import java.util.List;

import zdream.pmfield.data.foe.MoveAdditionalEffects;
import zdream.pmfield.data.foe.MoveTemplate;
import zdream.pmfield.stage.object.FoeActor;
import zdream.pmfield.stage.object.StageMove;

/**
 * 鸟族效果:
 * <li>虫族 {@link BugGroupBuff} 对你使用恶系技能伤害减少 0.5 级 (逻辑写在虫族里面)
 * <li>自动在 {@link FoeActor} 的 stageMoves 中补充起飞和落地两个技能
 * </li>
 *
 * @author Zdream
 * @date 2023-12-21
 * @since 0.0.1
 */
public class BirdGroupBuff extends AbilityBuff {
	public static final String CATEGORY = MoveAdditionalEffects.A_BIRD_GROUP;
	public static final int MOVE_FLYING = 10003;
	public static final int MOVE_LANDING = 10004;

	public BirdGroupBuff(BuffDescription description) {
		super(description);
	}

	@Override
	public String getCategory() {
		return CATEGORY;
	}

	@Override
	public String toString() {
		return "鸟族";
	}

	@Override
	public void init() {
		putFlyingMovesToFoes();
	}

	private void putFlyingMovesToFoes() {
		final List<StageMove> stageMoves = target.stageMoves;

		final boolean hasFlyingMove = stageMoves.stream().anyMatch(move -> move.move.id == MOVE_FLYING);
		final boolean hasLandingMove = stageMoves.stream().anyMatch(move -> move.move.id == MOVE_LANDING);

		if (!hasFlyingMove) {
			final MoveTemplate move = target.stage.storage.findMoveById(MOVE_FLYING, 1);
			target.stageMoves.add(new StageMove(target, move));
		}
		if (!hasLandingMove) {
			final MoveTemplate move = target.stage.storage.findMoveById(MOVE_LANDING, 1);
			target.stageMoves.add(new StageMove(target, move));
		}
	}
}
